1. Field of the Invention
The present invention relates to a method of communicating with an embedded controller, and more particularly to a method of communicating with an embedded controller under an advanced configuration and power interface specification (ACPI).
2. Description of the Related Art
The so-called ACPI stands for “Advanced Configuration and Power Interface Specification,” which was jointly set up by several companies, including HP, Intel, Microsoft, and Toshiba. Its purpose is to effectively control power via the operating system to save more power. Wherein, the specification defines what an embedded controller is. FIG. 1 is a schematic drawing showing an structure of an IBM personal computer's hardware. FIG. 1 comprises a central processing unit (CPU) 100, a north bridge chip 102, a south bridge chip 104, an LPC bus 106, and an embedded controller 108. In FIG. 1, the embedded controller 108 is disposed on the LPC bus 106 to control the power of the battery, temperature, and rotational speed of the fan.
The ACPI also defines a communication method between the operating system and the embedded controller. The ACPI also define a status register of an embedded controller. FIG. 2 is a drawing showing a status register of an embedded controller defined by a conventional ACPI. Referring to FIG. 2, the status register has 8 bits in total. The seventh bit Bit7 and the second bit Bit2 are IGN (ignore). The sixth bit Bit6 represents a system management interrupt event, SMI_EVT. When important events of the system management are to be transmitted, Bit6 is set as logic 1. The fifth bit Bit5 represents the system control interrupt event SCI_EVT. When important events of the system control are to be transmitted, Bit5 is set as logic 1. The fourth bit Bit4 represents BURST. The third bit Bit3 represents CMD. The first bit Bit1 represents input buffer full (IBF). When the operating system transmits commands or data to the embedded controller, but the embedded controller has yet accessed them, Bit1 is set as logic 1. The zeroth bit Bit0 represents output buffer full (OBF). When the embedded controller is going to transmit data to the operating system power management handler (OSPM), Bit0 is set as logic 1.
In an operating system which supports the ACPI, such as Microsoft Windows XP, if the platform is equipped with the embedded controller, and connects with a battery or a temperature sensor, the OSPM would periodically read related data concerning the remaining power of the battery or the temperature at that time. Practically, the OSPM communicates with the embedded controller through I/O interface ports 62h/66h. A schematic drawing of the structure is shown in FIG. 3. The flowchart of the above-mentioned is shown in FIG. 4. First, it is checked if OBF is logic 0 first. If not, it means that a previous output data is left on the I/O interface of the embedded controller. This output data is then read and removed. The said procedure is repeated until OBF is logic 0 (step 401). After that, it is checked if IBF is logic 0. If not, a previous input data on the I/O interface of the embedded controller needs to be read and removed by the embedded controller until IBF is logic 0 (step 403). When both steps 401 and 403 are done, the OSPM can then transmit commands to read data from or write data in the embedded controller if needed (step 405).
After commands are transmitted (step 407), IBF becomes logic 1. Step 407 should be continued until IBF becomes logic 0 (step 409). When IBF is confirmed as logic 0 and the index value to read the data is transmitted (step 411), wait until OBF becomes logic 1 (step 413). Next, read the data via I/O port (step 415). After the write command is transmitted (step 417), IBF becomes logic 1. Therefore, it is needed to wait until IBF becomes logic 0 (step 419). When IBF is confirmed as logic 0 and the index value to write data is transmitted (step 421), IBF becomes logic 1. After IBF turns to logic 0 (step 423), the data to be written are transmitted (step 425).
The ACPI provides a secure and safe method to allow the OSPM and the embedded controller to communicate and exchange information without errors. However, it does not provide a secure accessible mechanism that can be jointly used by other application programs or apparatus driving programs liked a device driver. This also means that the method is safe only when the OSPM can access the embedded controller. When IBF is logic 0, and an application program, such as a temperature monitoring and control software of the mother board, simultaneously access the embedded controller with the OSPM, a collision or interruption may occur or the system may even go down.